package com.lgCore.model;

import com.lgCore.util.StringUtils;

/**
 * rpc系统环境
 * Created by by on 2020/10/27 17:37
 */
public enum RpcSystemRegionEnum {
    //gray 走灰色服务，normal 走正常服务
    extraction("gray", "灰色服务"),
    inference("normal", "正常服务");
    private String region;
    private String message;
    RpcSystemRegionEnum(String region, String message) {
        this.region = region;
        this.message = message;
    }
    public static RpcSystemRegionEnum findByRegion(String region) {
        if(StringUtils.isNullOrEmpty(region)){
            //没有默认走正常服务
            return RpcSystemRegionEnum.inference;
        }
        RpcSystemRegionEnum[] rpcSystemRegionEnums = RpcSystemRegionEnum.values();
        for (int i = 0; i < rpcSystemRegionEnums.length; i++) {
            if (rpcSystemRegionEnums[i].getRegion().equals(region)) {
                return rpcSystemRegionEnums[i];
            }
        }
        //没有默认走正常服务
        return RpcSystemRegionEnum.inference;
    }

    public String getRegion() {
        return region;
    }

    public String getMessage() {
        return message;
    }
}
